Skip to content

Refactor protobuf flag abstraction layer to custom flag targets#28787

Draft
copybara-service[bot] wants to merge 1 commit into
mainfrom
test_952990495
Draft

Refactor protobuf flag abstraction layer to custom flag targets#28787
copybara-service[bot] wants to merge 1 commit into
mainfrom
test_952990495

Conversation

@copybara-service

@copybara-service copybara-service Bot commented Jul 23, 2026

Copy link
Copy Markdown

Refactor protobuf flag abstraction layer to custom flag targets

Instead of having rules depend on both native and Starlark versions of flags and reconciling them inside the rule implementation, this change moves the resolution logic into custom flag targets (compat_bool_flag and compat_string_list_flag) defined in third_party/protobuf/bazel/private/compat_flag.bzl.

Key details:

  • compat_bool_flag: Instantiates a string_flag with a "default" sentinel value to detect explicit Starlark flag settings vs. fallback to native config_setting matches or default values, providing a boolean BuildSettingInfo.
  • compat_string_list_flag: Defines a string-list build setting that reconciles explicit Starlark build settings with ctx.fragments.proto and default values.
  • Updates rule implementations under third_party/protobuf/bazel/private/ to consume custom flag targets directly.
  • Replaces native_bool_flag.bzl with compat_flag.bzl.

@copybara-service
copybara-service Bot force-pushed the test_952990495 branch 6 times, most recently from 7e6ef66 to b078688 Compare July 24, 2026 14:37
Instead of having rules depend on both native and Starlark versions of flags and reconciling them inside the rule implementation, this change moves the resolution logic into custom flag targets (`compat_bool_flag` and `compat_string_list_flag`) defined in `third_party/protobuf/bazel/private/compat_flag.bzl`.

Key details:
- `compat_bool_flag`: Instantiates a `string_flag` with a "default" sentinel value to detect explicit Starlark flag settings vs. fallback to native `config_setting` matches or default values, providing a boolean `BuildSettingInfo`.
- `compat_string_list_flag`: Defines a string-list build setting that reconciles explicit Starlark build settings with `ctx.fragments.proto` and default values.
- Updates rule implementations under `third_party/protobuf/bazel/private/` to consume custom flag targets directly.
- Replaces `native_bool_flag.bzl` with `compat_flag.bzl`.

PiperOrigin-RevId: 952990495
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant